/*
 * Copyright (C) 2018 Pingan, Inc. All Rights Reserved.
 */
package com.pingan.haofang.searchcloud.index.dto;

/**
 * 数据库列属性
 *
 * @author SONGBANGYONG396
 * @date 2018/8/22
 * @since 1.0.0
 */
public class ColumnModel {

    /**
     * 原始字段名
     */
    private String originColumnName;

    /**
     * 是否拥有别名
     */
    private boolean hasALias;

    /**
     * 最终字段名
     */
    private String finalColumnName;

    /**
     * solrType
     */
    private String solrType;

    /**
     * 是否函数
     */
    private boolean asFunction;

    /**
     * 函数名称
     */
    private String functionName;

    public ColumnModel() {
    }

    private ColumnModel(Builder builder) {
        setOriginColumnName(builder.originColumnName);
        setHasALias(builder.hasALias);
        setFinalColumnName(builder.finalColumnName);
        setSolrType(builder.solrType);
        setAsFunction(builder.asFunction);
        setFunctionName(builder.functionName);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getOriginColumnName() {
        return originColumnName;
    }

    public void setOriginColumnName(String originColumnName) {
        this.originColumnName = originColumnName;
    }

    public boolean isHasALias() {
        return hasALias;
    }

    public void setHasALias(boolean hasALias) {
        this.hasALias = hasALias;
    }

    public String getFinalColumnName() {
        return finalColumnName;
    }

    public void setFinalColumnName(String finalColumnName) {
        this.finalColumnName = finalColumnName;
    }

    public String getSolrType() {
        return solrType;
    }

    public void setSolrType(String solrType) {
        this.solrType = solrType;
    }

    public boolean isAsFunction() {
        return asFunction;
    }

    public void setAsFunction(boolean asFunction) {
        this.asFunction = asFunction;
    }

    public String getFunctionName() {
        return functionName;
    }

    public void setFunctionName(String functionName) {
        this.functionName = functionName;
    }


    public static final class Builder {
        private String originColumnName;
        private boolean hasALias;
        private String finalColumnName;
        private String solrType;
        private boolean asFunction;
        private String functionName;

        private Builder() {
        }

        public Builder originColumnName(String val) {
            originColumnName = val;
            return this;
        }

        public Builder hasALias(boolean val) {
            hasALias = val;
            return this;
        }

        public Builder finalColumnName(String val) {
            finalColumnName = val;
            return this;
        }

        public Builder solrType(String val) {
            solrType = val;
            return this;
        }

        public Builder asFunction(boolean val) {
            asFunction = val;
            return this;
        }

        public Builder functionName(String val) {
            functionName = val;
            return this;
        }

        public ColumnModel build() {
            return new ColumnModel(this);
        }
    }

    @Override
    public String toString() {
        return "ColumnModel{" +
                "originColumnName='" + originColumnName + '\'' +
                ", hasALias=" + hasALias +
                ", finalColumnName='" + finalColumnName + '\'' +
                ", solrType='" + solrType + '\'' +
                ", asFunction=" + asFunction +
                ", functionName='" + functionName + '\'' +
                '}';
    }
}
